package com.computergames.server.service.GameStrategy;

import com.computergames.server.message.MoveRequestMessage;
import com.computergames.server.service.Implement.LandlordMessageHandlerFactory;
import com.computergames.server.util.SpringUtil;
import io.netty.channel.ChannelHandlerContext;

import java.util.Set;


public class LandlordMessageHandler implements MessageHandlingStrategy{
    @Override
    public int handle(MoveRequestMessage msg, String roomName, ChannelHandlerContext ctx) {
        LandlordMessageHandlerFactory factory = SpringUtil.getBean(LandlordMessageHandlerFactory.class);
        int result = factory.getRuleDetermination().ruleDetermination(roomName, msg.getContent(), ctx);
        factory.getGameStorage().save(roomName, msg.getContent(), result, ctx);
        return result;
    }
}
